package com.bdqn.service.impl;

import com.bdqn.entity.PsUser;
import com.bdqn.mapper.PsUserMapper;
import com.bdqn.service.IPsUserService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dede
 * @since 2020-05-22
 */
@Service
public class PsUserServiceImpl extends ServiceImpl<PsUserMapper, PsUser> implements IPsUserService {
	@Autowired
	PsUserMapper psUserMapper;

	@Override
	public IPage<PsUser> qwer(int roleid, int rid, int pageNum, int pageSize) {
		 QueryWrapper<PsUser> qw=new QueryWrapper<>();

	        qw.like("u.roleid", roleid).eq("r.id", rid);
		return psUserMapper.qwer(new Page<>(pageNum,pageSize), qw);
	}

	@Override
	public PsUser checkLogin(String name, String pwd) {
		 QueryWrapper<PsUser> qw=new QueryWrapper<>();
		 qw.eq("u.usercode", name).eq("u.USERPASSWORD", pwd);
		return psUserMapper.checkLogin(qw);
	}

	@Override
	public List<PsUser> selectRole() {
		QueryWrapper<PsUser> qw=new QueryWrapper<>();
		qw.like("u.username", "巡检员");
		return psUserMapper.selectRole(qw);
	}

	@Override
	public PsUser selectCode(String string) {
		QueryWrapper<PsUser> qw=new QueryWrapper<>();
		qw.like("u.usercode", string);
		return psUserMapper.selectCode(qw);
	}
}
